//
//  LXPhotoView.m
//  微了个小博
//
//  Created by imera on 15/10/17.
//  Copyright (c) 2015年 imera. All rights reserved.
//

#import "LXPhotoView.h"
#import "UIImageView+WebCache.h"
#import "LXPhoto.h"

@interface LXPhotoView()
/** gif标识 */
@property (nonatomic, weak) UIImageView *gifView;

@end

@implementation LXPhotoView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        //添加gif标识
        UIImage *image = [UIImage imageWithName:@"timeline_image_gif"];
        UIImageView *gifView = [[UIImageView alloc]initWithImage:image];
        
        [self addSubview:gifView];
        self.gifView = gifView;
    }
    return self;
}

- (void)setPhoto:(LXPhoto *)photo
{
    _photo = photo;
    
    self.gifView.hidden = ![photo.thumbnail_pic hasPrefix:@"gif"];
    
    [self sd_setImageWithURL:[NSURL URLWithString:photo.thumbnail_pic]];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.gifView.layer.anchorPoint = CGPointMake(1, 1);
    self.gifView.layer.position = CGPointMake(self.frame.size.width, self.frame.size.height);

}

@end
